var vm = new Vue({
            el: '#rrapp',
            data:{types:[]},
            created: function(){
                this.initMemu();
            },
            methods: {
                initMemu:function(){
                    var $this = this;
                    $.ajax({
                        url : '../../business/alwaysuse/useMenuChoseList',
                        dataType:'json',
                        type:'post',
                        success: function(res){
                            if(res.code === '0'){
                                $this.types = res.data;
                                console.log($this.types);
                                }
                            }
                    });
                }
            }
            });

function initMemu(){
	$.ajax({
		url : '../../business/alwaysuse/useMenuChoseList',
		dataType:'json',
		type:'post',
		async:true,
		success: function(res){
			if(res.code === '0'){
			    this.types = res.data;
			    console.log(this.types);
				var data= res.data;
				var html = '';
				for(var i = 0 ; i < data.length ; i++){
					html += '<li><input type="checkbox" name="menuIds" value="' + data[i].menuId + '"';
					if(data[i].isUse === '1'){
						html += ' checked="checked" ';
					}
					html += '/>' + data[i].name + '</li>';
				}
				$("#menuTree").html(html);
				$("#buttonDiv").show();
			}else{
				alert(res.msg);
			}
		},
		error: function(){
			alert('获取菜单失败!');
		}
	});
}

function saveData(){
	var menuIds = '';
	$("input[type='checkbox']:checked").each(function(i, n){ 
		menuIds += $(this).val() + ',';
	});
	if(menuIds != ''){
		menuIds = menuIds.substr(0,menuIds.length - 1);
	}
	$("#sub").attr('style','display:none')
	$.ajax({
		url : '../../business/alwaysuse/saveData',
		dataType:'json',
		type:'post',
		data:{
			'menuIds' : menuIds
		},
		success: function(res){
			if(res.code === '0'){
				parent.getAlwaysUse();
				parent.layer.msg('常用功能设置成功');
				parent.layer.close(parent.pageii);
			}else{
				alert(res.msg);
			}
		}
	})
}

/*//菜单树
var menu_ztree;
var menu_setting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "menuId",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url:"nourl"
        }
    },
    check:{
        enable:true,
        nocheckInherit:true
    }
};


var vm = new Vue({
    el:'#rrapp',
    data:{
    },
    methods: {
        getMenuTree: function() {
            //加载菜单树
            $.get("../../sys/menu/nav", function(r){
                menu_ztree = $.fn.zTree.init($("#menuTree"), menu_setting, r);
                //展开所有节点
                menu_ztree.expandAll(true);
            });
        },
    },
    mounted(){
    	this.getMenuTree()
    }
});*/



